import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref('')
    const user = ref({
      id: '',
      username: '',
      password: '',
      email: '',
      avatar: '',
      createTime: '',
      updateTime: '',
      status: '',
      role: '',
      token: ''
    })

    const setToken = (tokenValue) => {
      token.value = tokenValue
    }
    const setUser = (newUser) => {
      user.value = newUser
    }

    return {
      token,
      setToken,
      user,
      setUser
    }
  },
  {
    persist: {
      key: 'ONLINE_MUSIC_KEY'
    }
  }
)
